// Copyright (C) ustc9703
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-7-12

#include "stdafx.h"
#include ".\threadpool.h"
//#include "server.h"

void CJoyAsyObject::Cancel()
{
    _InterlockedDecrement((LONG*)&m_asyState);
}

void CJoyAsyObject::Execute()
{
    if(_InterlockedIncrement((LONG*)&m_asyState) > 0)
    {
        OnExecute();
    }
    _InterlockedDecrement((LONG*)&m_asyState);
}

void CJoyAsyObject::Finish()
{
    if(m_asyState == 0)
    {
        OnFinish();
    }
}

// class CJoyThreadWorker

void CJoyThreadWorker::Execute(RequestType pAsyObj, void *, OVERLAPPED* ) throw()
{
    pAsyObj->Execute();
	delete pAsyObj;
//    PostMessage(g_server->AsyWnd(), AM_FinishAsyObject, (WPARAM)pAsyObj, 0);
}

// class CJoyThreadPool

CJoyThreadPool::CJoyThreadPool(void)
{
}

CJoyThreadPool::~CJoyThreadPool(void)
{
}
